
import mongoose from 'mongoose';
// 用户相关类型
export interface User {
  id: string;
  roles?: string[];
  name: string;
  email: string;
  sex?: number;
  password?: string;
  age?: number;
  isActive: boolean;
  lastLogin?: Date;
  createdAt?: Date;
  updatedAt?: Date;
}
// 角色相关类型
export interface Role {
  name: string;
  code: string;
  description?: string;
  type: mongoose.Schema.Types.ObjectId;
  sort: number;
  tenantId: mongoose.Schema.Types.ObjectId;
  isActive: boolean;
  createdBy: mongoose.Schema.Types.ObjectId,
  updatedBy: mongoose.Schema.Types.ObjectId,
}
export interface Tenant {
  name: string;
  code: string;
  isActive: boolean;
  createdBy: mongoose.Schema.Types.ObjectId,
  updatedBy: mongoose.Schema.Types.ObjectId,
}
export interface Info {
  id: string;
  title: string;
  content: string;
  type: 'system' | 'notice' | 'task' | 'alert';
  status: 'unread' | 'read';
  receiverId: string;
  receiverType: 'user' | 'role' | 'all';
  senderId?: string;
  createdAt: Date;
  readAt?: Date;

}

export interface Dic {
  type: string;
  value: any,
  label: string;
  sort: number;
  isActive: boolean;
  isDefault?: boolean;
  remark?: string;
  createdBy?: mongoose.Schema.Types.ObjectId,
  updatedBy?: mongoose.Schema.Types.ObjectId,
}
// 权限相关类型
export interface Permission {
  type: 'button' | 'menu';
  name?: string; // sort:read:all 
  createdBy?: mongoose.Schema.Types.ObjectId,
  updatedBy?: mongoose.Schema.Types.ObjectId,
  pageId: mongoose.Schema.Types.ObjectId,
  roleId?: mongoose.Schema.Types.ObjectId,
}
export interface Menu {
  // 核心必填字段
  // name: string;
  path: string;
  component: string;
  title: string;
  sort: number;
  isActive: boolean;
  // 结构与关系
  parentId: mongoose.Schema.Types.ObjectId | null;
  redirect?: string;
  type: 'contents' | 'page';
  //导航与 UI 显示字段
  breadcrumb?: boolean;
  noCache?: boolean;
  affix?: boolean;
  linkSrc?: string;
  newWindow?: boolean;
  icon?: string;
  hidden: boolean;
  // 权限与安全
  tenantId?: mongoose.Schema.Types.ObjectId;
  // 扩展字段
  meta?: Record<string, any>;
  // 结构与关系
  createdAt: Date;
  updatedAt: Date;
  createdBy?: mongoose.Schema.Types.ObjectId,
  updatedBy?: mongoose.Schema.Types.ObjectId,
}

// 错误响应类型
export interface ErrorResponse {
  error: string;
  message: string;
  details?: any;
  timestamp: string;
}

